//
//  KNavigationViewController.m
//  TimeToCoin
//
//  Created by QuanLi on 2018/8/1.
//  Copyright © 2018年 QuanLi Technology Limited. All rights reserved.
//

#import "KNavigationViewController.h"


@interface KNavigationViewController ()

@end

@implementation KNavigationViewController



//+ (void)initialize
//{
//    
//    
//    [[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
//    
//    
//    
//    //       [[UINavigationBar appearance] setBarTintColor:WJColor(255, 255, 255, 1)];
//    //设置整个项目所有BarButtonItem的主题样式
//    UIBarButtonItem *item = [UIBarButtonItem appearance];
//    
//    //设置普通状态
//    //key NS*********AttributeName
//    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
//    
//    //textAttrs[NSForegroundColorAttributeName] = WJColor(35, 177, 209, 1);
//    textAttrs[NSForegroundColorAttributeName] = WJColor(33, 33, 33, 1);
//    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:15];
//    [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
//    
//    
//    //设置不可用状态
//    NSMutableDictionary *disabletextAttrs = [NSMutableDictionary dictionary];
//    
//    disabletextAttrs[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
//    disabletextAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:15];
//    [item setTitleTextAttributes:disabletextAttrs forState:UIControlStateDisabled];
//    
//    
//    
//    //设置导航栏标题文字的颜色
//    //    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
//    
//    //改变导航条字体为白色
//    //    NSFontAttributeName:[UIFont systemFontOfSize:19]
//    
//    
//    //[[UINavigationBar appearance] setTitleTextAttributes: @{NSForegroundColorAttributeName:MCColor(35, 177, 209, 1)}];
//    
//    [[UINavigationBar appearance] setTitleTextAttributes: @{NSForegroundColorAttributeName:WJColor(33, 33, 33, 1)}];
//    
//    
//    //设置默认按钮颜色
//    [[UINavigationBar appearance] setTintColor:WJColor(33, 33, 33, 1)];
//    
//    
//}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    //设置导航栏不透明
    self.navigationBar.translucent = NO;
    
    [self.navigationBar setShadowImage:[[UIImage alloc]init]];
}

/**
 *  重写这个方法的目的：能够拦截所有push进来的控制器
 *
 *  @param viewController 即将push进来的控制器
 *  @param animated       是否带动画效果
 */
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count > 0) {   //这时PUSH进来的控制器不是第一个控制器（根控制器）
        
        /* 自动显示或者隐藏tabbar  */
        
        viewController.hidesBottomBarWhenPushed = YES;
        
        self.backItem = [UIBarButtonItem itemWithTarget:self action:@selector(onBack) image:@"back-black" highImage:@"back-black"];
        
        viewController.navigationItem.leftBarButtonItem = self.backItem;
        
        
        // 滑动返回功能
        self.interactivePopGestureRecognizer.delegate = nil;
        
    }
    [super pushViewController:viewController animated:animated];
}

- (void)onBack
{
    [self popViewControllerAnimated:YES];
}

@end
